<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>雨水飘落</title>
    <style>
        html,
        body {
            height: 100%;
            border: 0;
            padding: 0;
            margin: 0;
        }

        body {
            background-color: rgb(192, 81, 7,.6);
            width: 100%;
            height: 100%;
        }
    </style>
</head>

<body>
    <script>
        function Sprin(a) {
            var rain = document.createElement('div');
            rain.style.position = 'absolute';
            rain.style.width = Math.random() * 5 + 'px';
            rain.style.height = Math.random() * 50 + 'px';
            // rain.style.borderTopLeftRadius = '100px';
            // rain.style.borderTopRightRadius = '100px';
            // rain.style.borderBottomLeftRadius = '100px';
            // rain.style.borderBottomRightRadius = '100px';
            rain.style.borderRadius = '50%';
            rain.style.backgroundColor = 'white';
            rain.style.transform = 'rotate(-20deg)'
            document.body.appendChild(rain);

            var left = document.documentElement.clientWidth * Math.random();
            var top = document.documentElement.clientHeight * Math.random();

            rain.style.left = left + 'px';
            rain.style.top = top + 'px';

            function move() {
                left = left + 5 *a;
                top = top + 20 *a ;
                if (left > document.documentElement.clientWidth * 0.9) { left = 50 }
                if (top > document.documentElement.clientHeight * 0.8) { top = 50 }
                rain.style.left = left + 'px';
                rain.style.top = top + 'px';
                rain.style.backgroundColor = 'hsl(' + Math.floor(Math.random() * 360) + ',100%,60%)'; 
                requestAnimationFrame(move);
            }
            move()
        }
        for (var i = 0; i <= 50; i++) {
            new Sprin(Math.random());
        }

    </script>
</body>

</html>